package cn.chuanw.db.service;

import cn.chuanw.db.dao.WRoomreturnRecordMapper;
import cn.chuanw.db.domain.WRoomreturnRecordExample;
import com.github.pagehelper.PageHelper;
import cn.chuanw.db.domain.WRoomreturnRecord;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Auther: wangkun
 * @Date:  20-02-09 下午 4:02
 * @Description: 租户退房记录类
 **/
@Service
public class RoomreturnRecordService {
    @Resource
    private WRoomreturnRecordMapper wRoomreturnRecordMapper;

    public List<WRoomreturnRecord> querySelective(String tenantId, Integer page, Integer size) {
        WRoomreturnRecordExample wRoomreturnRecordExample = new WRoomreturnRecordExample();
        WRoomreturnRecordExample.Criteria criteria = wRoomreturnRecordExample.createCriteria();
        if (!StringUtils.isEmpty(tenantId)) {
            criteria.andTenantIdEqualTo(tenantId);
        }
        PageHelper.startPage(page, size);
        return wRoomreturnRecordMapper.selectByExample(wRoomreturnRecordExample);
    }

    public void create(WRoomreturnRecord wRoomreturnRecord) {
        wRoomreturnRecordMapper.insertSelective(wRoomreturnRecord);
    }

    public int updateById(WRoomreturnRecord wRoomreturnRecord) {
        return wRoomreturnRecordMapper.updateByPrimaryKeySelective(wRoomreturnRecord);
    }

}
